classdef condonemax < fitness
    properties
       orderindex; 
    end
    
    methods
        function obj = condonemax(orderindex)
            obj.orderindex =orderindex;
        end
        function fit = getfit(obj, pop)
            [K, J] = size(pop);
            fit = zeros(1,J);
            for i=1:K
                xind = obj.orderindex(1);
                fit(xind) = fit(xind) + pop(i, xind);
                for j=2 :J
                    xind = obj.orderindex(j-1);
                    prevvalue =  pop(i, xind);
                    yindx = obj.orderindex(j);
                    if prevvalue == 1
                        curvalue = pop(i, yindx);
                        fit(yindx) = fit(yindx) + curvalue;
                    else
                        fit(yindx) = fit(yindx) -1;
                    end
                        
                        
                end
            end
        end
    end
    
end

